package com.selftool.gui.serverframe.action;

import com.selftool.base.NCButton;
import com.selftool.log.Logger;
import com.selftool.util.CommonUtil;
import com.selftool.util.HttpConnection;
/**
* @Description: 检查更新按钮
* @Author: CYQ
* @Date: 2024/2/20
*/
public class UpdatesButton extends NCButton {

    /**
     * @param obj
     * @throws Exception
     */
    @Override
    protected void execute(Object obj) throws Exception {
        try{
            Logger.write("正在检查更新...");
            String filePath = System.getProperty("user.dir")+ "/selftool.jar";
            String md5 = CommonUtil.md5HashCode(filePath);
            String url = CommonUtil.getParameter("checkurl");

            String json = "{\"code\":\"RE_SELF_CHECK\",\"data\":{\"md5\":\""+md5+"\"}}";
            String ret = HttpConnection.doPost(url,json,null);
            Logger.write("检查结果为..."+ret);
        }catch (Exception e){
            Logger.write("很抱歉,检查更新失败,您可通过【https://gitee.com/sillage_c/selftool】与我取得联系并反馈问题，感谢您的支持！");
        }
    }
}
